This page is under development. Comments are welcome, but please load any comments in the comments section at the bottom of the page. Please include your wiki MONIKER and date in your comment with the same courtesy that I will give you. Aside from your courtesy, your wiki MONIKER and date as a signature and minimal good faith of any internet post are the rules of this TCL-WIKI. Its very hard to reply reasonably without some background of the correspondent on his WIKI bio page. Thanks, gold 12Dec2018
gold Here is an eTCL script on to estimate the Drake equation. For the push buttons, the recommended procedure is push testcase and fill frame, change entries , push solve, and then push report. Report allows copy and paste from console.
In planning any software, there is a need to develop testcases. Testcase ! is the original numbers that Drake used. Testcase 2 is the revision or follow-up numbers from the National Radio Astronomy Observatory.
quantity | number | units |
---|---|---|
star formation | 10. | rate per year |
stars with planets | .5 | stars |
potential life | 2. | |
actual life | 1. | |
fraction develop civilization | .01 | none |
fraction technology | .01 | none |
years available | 10000. | years |
number of civilizations equal 10.* .5 * 2. * 1. * .01 * .01 * 10000. | ||
answer: 10. | civilizations |
table 2 | printed in | tcl format |
---|---|---|
quantity | value | comment, if any |
testcase number: | 1 | |
1. : | star formation per year: | |
.4 : | fraction stars with planets: | |
1. : | possible life : | |
0.5 : | actual life: | |
.5 : | civilization develop: | |
.5 : | detectable signs: | |
10000. : | length years: | |
expr { side1 * side2 * side3 * side4 * side5 * side6 * side7 } | internal variables for estimated number of civilizations: | |
expr { 1. * .4 * 1. * 0.5 * .5 * .5 * 10000. } | math expression for estimated number of civilizations: | |
500.0 : | estimated number of civilizations: |
# Pretty print version from autoindent # and ased editor # program of drake equation # written on Windows XP on eTCL # working under TCL version 8.5.6 and eTCL 1.0.1 # gold on TCL Club , 24aug2010 # comment follows from gold, 12Dec2018 # pretty print from autoindent and ased editor # Drake Equation Calculator V2 # written on Windows XP on TCL # working under TCL version 8.6 # Revamping older program from 24Aug2010. # One of my early and first TCL programs on wiki, # but I believe the Drake Equation # might have some interest (to me & et. ). frame .frame -relief flat -bg aquamarine4 pack .frame -side top -fill y -anchor center set names {{} {star formation per year:} {fraction stars with planets:} {possible life :} {actual life:} {civilization develop:} {detectable signs:} {length years:} { estimated number of civilizations:} } foreach i {1 2 3 4 5 6 7 8} { label .frame.label$i -text [lindex $names $i] -anchor e entry .frame.entry$i -width 35 -textvariable side$i grid .frame.label$i .frame.entry$i -sticky ew -pady 2 -padx 1 } proc about {} { set msg "Calculator for Drake Equation V2 from TCL Club, # gold on TCL Club , 12Dec2018 " tk_messageBox -title "About" -message $msg } proc self_help {} { set msg " Drake Equation V2 from TCL Club, # self help listing # problem, Drake Equation V2 # 7 givens follow. 1) star formation per year: 2) fraction stars with planets: 3) possible life: 4) actual life: 5) civilization develop: 6) detectable signs: 7) length years: # Recommended procedure is push testcase # and fill frame, # change first three entries etc, push solve, # and then push report. # Report allows copy and paste # from console to conventional texteditor. # For testcases, testcase number is internal # to the calculator and will not be printed # until the report button is pushed # for the current result numbers. # >>> copyright notice <<< # This posting, screenshots, and TCL source code is # copyrighted under the TCL/TK license terms. # Editorial rights and disclaimers # retained under the TCL/TK license terms # and will be defended as necessary in court. Conventional text editor formulas or formulas grabbed from internet screens can be pasted into green console. # gold on TCL Club, 12Dec2018 " tk_messageBox -title "Self_Help" -message $msg } proc intelligent5 { xx1 } { global side1 side2 side3 global side4 side5 side6 side7 side8 set side8 [ expr { 1.*$side1*$side2*$side3*$side4*$side5*$side6*$side7 } ] return $side8 } proc calculate { } { global answer2 global side1 side2 side3 side4 side5 side6 side7 side8 global testcase_number drake_equation global drake_equation_variables incr testcase_number # develop math expression for printout set drake_equation_variables "expr \{ side1 * side2 * side3 * side4 * side5 * side6 * side7 \} " set drake_equation "expr \{ $side1 * $side2 * $side3 * $side4 * $side5 * $side6 * $side7 \} " set answer2 [ intelligent5 $side8 ] set side8 $answer2 } proc fillup {aa bb cc dd ee ff gg hh} { .frame.entry1 insert 0 "$aa" .frame.entry2 insert 0 "$bb" .frame.entry3 insert 0 "$cc" .frame.entry4 insert 0 "$dd" .frame.entry5 insert 0 "$ee" .frame.entry6 insert 0 "$ff " .frame.entry7 insert 0 "$gg " .frame.entry8 insert 0 "$hh " } proc clearx {} { foreach i {1 2 3 4 5 6 7 8} { .frame.entry$i delete 0 end } } proc reportx {} { global side1 side2 side3 side4 side5 global side6 side7 side8 global testcase_number global activation_default drake_equation global drake_equation_variables console eval {.console config -bg palegreen} console eval {.console config -font {fixed 20 bold}} console eval {wm geometry . 40x20} console eval {wm title . " Drake Equation V2 Report, screen grab and paste from console 2 to texteditor"} console eval {. configure -background orange -highlightcolor brown -relief raised -border 30} console show; puts "%|table $testcase_number|printed in| tcl format|% " puts "&| quantity| value| comment, if any|& " puts "&| testcase number:|$testcase_number | |&" puts "&| $side1 :|star formation per year:| |&" puts "&| $side2 :|fraction stars with planets: | |& " puts "&| $side3 :|possible life : | |& " puts "&| $side4 :|actual life: | |&" puts "&| $side5 :|civilization develop: | |&" puts "&| $side6 :|detectable signs:| |& " puts "&| $side7 :|length years:| |&" puts "&| $drake_equation_variables |internal variables for estimated number of civilizations:| |&" puts "&| $drake_equation |math expression for estimated number of civilizations:| |&" puts "&| $side8 :|estimated number of civilizations: | |&" } frame .buttons -bg aquamarine4 ::ttk::button .calculator -text "Solve" -command { calculate } ::ttk::button .test2 -text "Testcase1" -command {clearx;fillup 10. .5 2. 1. .01 .01 10000. 10.} ::ttk::button .test3 -text "Testcase2" -command {clearx;fillup 10. .5 2. 1. .01 .01 10000. 10. } ::ttk::button .test4 -text "Testcase3" -command {clearx;fillup 1. .4 1. 0.5 .5 .5 10000. 500. } ::ttk::button .clearallx -text clear -command {clearx } ::ttk::button .about -text about -command about ::ttk::button .self_help -text self_help -command { self_help } ::ttk::button .cons -text report -command { reportx } ::ttk::button .exit -text exit -command {exit} pack .calculator -in .buttons -side top -padx 10 -pady 5 pack .clearallx .cons .self_help .about .exit .test4 .test3 .test2 -side bottom -in .buttons grid .frame .buttons -sticky ns -pady {0 10} . configure -background aquamarine4 -highlightcolor brown -relief raised -border 30 wm title . "Drake Equation Calculator V2 "
Please place any comments here, Thanks.
What is your purpose in binding the motion event on your main window to execute the wm title command. I.e., this line:
bind . <Motion> {wm title . "Drake Equation Calculator "}
The result of that binding is that every time you move the mouse, the "wm title" subcommand is called repeatedly. To set the window title, you just need to call "wm title . title" once, not on every event update upon mouse pointer motion.
Also, why do you define the procs pi, interlinear, pol, errorx, and height5 when you do not appear to use them anywhere in the code presented? In examples, having extra bits defined that are not used adds noise that a reader has to expend effort upon only to later learn that he/she could have ignored that part. Keeping the example focused upon only that which is needed for just the example, and nothing more, makes for a more informative, and educational, example.
gold changes: pulled procs pi,interlinear,pol,errorx,height5. and changed to wm . "title".
Former idea was that user could use interpolate routine in the punched console. Conjecture below was that in a namespace version, subroutines would be available, but not all called from the namespace.
In that case, you might consider placing them into a namespace (i.e. ::gold::) and placing that common code on your main "gold" page. Then each other example page can refer to that one common location for the common items. Of course you would want to modify the examples to both load the ::gold definitions file from the gold page, and to make use of the procs therein instead of defining each individually.
Please include your wiki MONIKER and date in your comment with the same courtesy that I will give you.Thanks, gold 12Dec2018
Category Numerical Analysis | Category Toys | Category Calculator | Category Mathematics | Category Example | Toys and Games | Category Games | Category Application | Category GUI |